<template>
  <div id="noticeProfilePage">
    <div class="title">{{ noticeData?.title }}</div>
    <div class="createtime">{{ dayjs(noticeData?.createTime).format('YYYY-MM-DD') }}</div>
    <div class="content" v-html="noticeData?.content"></div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import { getNoticeByIdUsingGet } from '@/api/noticeController.ts'
import { message } from 'ant-design-vue'
import dayjs from 'dayjs'

const route = useRoute()
const noticeData = ref<API.Notice>()

onMounted(async () => {
  const id = route.params.id
  const res = await getNoticeByIdUsingGet({ id })
  if (res.data.code === 0 && res.data.data !== null) {
    noticeData.value = {
      ...res.data.data,
    }
  } else {
    message.error('获取数据失败' + res.data.message)
  }
})
</script>

<style scoped>
#noticeProfilePage {
  padding: 16px;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 16px;
}

.title {
  font-size: 22px;
  font-weight: bold;
}

.content {
  //text-align: center;
  max-width: 60%;
}

</style>
